/*
 * Class Input
 */
Input.prototype = new Element();
Input.prototype.constructor = Element;
Input.prototype.value = '';
Input.prototype.label = '';
Input.prototype.placeHolder = '...placeholder';
Input.prototype.itype = ''//text, password, checkbox, radio, checkboxgroup...;
Input.prototype._isInner = false;
Input.prototype._parent = {};
//Input.prototype.btInputClass = 'input-medium';//btn-info, btn-success, btn-link, .., btn-block
Input.prototype.btInputSize = 'input-medium';//input-medium, input-small

Input.prototype.makeHtml = function(){
    var cssWidth = "";
    var _this = this;
    
    this.Classes.push(this.CLASSNAMES.Input);
    this.Classes.push(this.btInputClass);
    this.Classes.push(this.btInputSize);
    
    if(this.width == '100%')    this.Classes.push('btn-block');
    else{
        if(this.width){
            cssWidth = ' width:'+this.width;
        }
    }
    
    var classes = this._getClassesString();
    var html;
    switch(this.itype){
        case 'textfield':
            html = _this._getTextfield(_this._parent.layout, classes);
        break;
    }
    return html;
};

Input.prototype._getTextfield = function(layout){
    var html = '';
    if(!layout) layout = 'hbox';
    if(layout == 'hbox'){
        this.Classes.push(this.CLASSNAMES.TEXTFIELD_HBOX);
        var classes = this._getClassesString();
        html = '<input type="text" name="'+this.name+'" class="'+classes+'" placeholder="'+this.placeHolder+'">';
    }
    else{
        if(layout == 'vbox'){
            this.Classes.push(this.CLASSNAMES.TEXTFIELD_VBOX);
            var classes = this._getClassesString();
            html =  '<div class="rck-control-group">'+
                        '<label class="rck-control-label" for="'+this.id+'">'+this.label+'</label>'+
                        '<div class="controls">'+
                        '<input name="'+this.name+'" type="text" id="'+this.id+'" placeholder="'+this.placeHolder+'">'+
                        '</div>'+
                    '</div>';
        }
    }
    return html;
}

//
Input.prototype.create = function(options){
//    this._id = this.makeUId();
    var _this = this;
    
    this.setOptions(options);
    
    var jId = "#"+this.id;
    var jRenderTo = "#"+this.renderTo;
    
    //si posee tag donde insertar html
    if(this.renderTo){
        //create DOM element
        jQuery(jRenderTo).html(this.makeHtml());
        
        //setting widths
        if(this.width)
            this.setWidth(this.width);
        if(this.height)
            this.setHeight(this.height);
        
        //the object exist in DOM, we create the handler event
    }
    else{
    }
    
    return this;
}

function Input(options){
//    console.log(options)
    this.create(options);
}

TextField.prototype = new Element();
TextField.prototype.constructor = Element;

function TextField(options){
    options.itype = 'textfield';
    return new Input(options);
}